import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

public class Leet3 {
        public int lengthOfLongestSubstring(String s) {
            if(s.length()==1)
                return 1;
            char[] c = s.toCharArray();
            int max = 0;
            for(int i = 0;i < c.length-1;i++){
                Set set = new HashSet();
                int f,l;
                for(int j =i;j<c.length;j++){
                    f = set.size();
                    set.add(c[j]);
                    l = set.size();
                    if(f==l)
                        break;
                }
                max = Math.max(max,set.size());
            }

            return max;
        }

}
